<template>
  <div >
    <a-form-model class="fromModels" ref="privacyagreementModel" layout="vertical"  labelAlign="right"
    :labelCol="{span: 8}" :wrapperCol="{span: 16}">
        <a-form-model-item label="修正比例" >
          <div class="steps">
            <a-button :disabled="yebzystemFroms.amend_scale<=0.1" icon="minus" @click="numchanes(1)"></a-button>
            <a-input-number  v-model="yebzystemFroms.amend_scale"
                :default-value="0.1" :max='1' :min='0' step="0.1" :precision="1"
              />
            <a-button :disabled="yebzystemFroms.amend_scale>=1" icon="plus" @click="numchanes(2)"></a-button>
          </div>
        </a-form-model-item>
        <a-form-model-item label="结束时间点" >
          <a-time-picker v-model="yebzystemFroms.amend_end_time"  valueFormat="HH:mm" format="HH:mm" />
        </a-form-model-item>
        <a-form-model-item label="是否开启自动处理" >
          <a-radio-group v-model="yebzystemFroms.amend_enable">
            <a-radio :value="0"> 关闭 </a-radio>
            <a-radio :value="1"> 开启 </a-radio>
          </a-radio-group>
        </a-form-model-item>
        <a-form-model-item  :wrapper-col="{ span: 21, offset:8 }">
          <a-button type="primary" @click="saveInfo">保存</a-button>
          <a-button style="margin: 0 10px;"  @click="resterInfor">重置</a-button>
          <a-button type="primary"  @click="saveInfo">同步品牌</a-button>
        </a-form-model-item>
    </a-form-model>
  </div>
</template>

<script>
import { getConfigAmendBalanceNotEnough,writeConfigAmendBalanceNotEnough } from '@/api/system.js'
export default {
  name: '',
  
  data() {
      return {
        yebzystemFroms:{
          amend_scale:0,
          amend_end_time:'09:00',
          amend_enable:0,
        }
      }
  },
  created(){
    this.getDataInfor()
  },
  methods:{
    numchanes(nums){
      if(nums==2){
        this.yebzystemFroms.amend_scale=Number(this.yebzystemFroms.amend_scale)+0.1
        if(this.yebzystemFroms.amend_scale>1){
          this.yebzystemFroms.amend_scale=1
        }
      }else{
        this.yebzystemFroms.amend_scale=Number(this.yebzystemFroms.amend_scale)-0.1
        if(this.yebzystemFroms.amend_scale<0){
          this.yebzystemFroms.amend_scale=0
        }
      }
    },
    resterInfor(){
      this.yebzystemFroms={
          amend_scale:0.1,
          amend_end_time:'',
          amend_enable:0,
        }
    },
    saveInfo(){
      writeConfigAmendBalanceNotEnough({
        brand_id: process.env.VUE_APP_BRAND_ID,...this.yebzystemFroms}).then(res=>{
        this.$message.success("操作成功");
      })
    },
    getDataInfor(){
      getConfigAmendBalanceNotEnough({
        brand_id: process.env.VUE_APP_BRAND_ID,}).then(res=>{
        this.yebzystemFroms={
          amend_scale:res.data.amend_scale,
          amend_end_time:res.data.amend_end_time,
          amend_enable:res.data.amend_enable
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.steps{
  display: flex;
  align-items: center;
}
/deep/ .ant-form-vertical .ant-form-item-label{
  text-align: right;
  padding-right: 10px;
}
/deep/ .ant-form-vertical .ant-form-item-label::after{
  content: '：';
}
</style>
